<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件</title>
    <!-- 引入vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <h3>hello,{{name}}</h3>
        <input type="text" placeholder="按下回车提示输入" @keyup.huiche="showInfo">
    </div>
    <script>
        Vue.config.productionTip = false // 以阻止 vue 在启动时生成生产提示。
        Vue.config.keyCodes.huiche = 13

        new Vue({
            el: "#root",
            data: {
                name: 'yykk'
            },
            methods: {
                showInfo(event) {
                    // console.log(event.key);
                    // if (event.keyCode != 13) return // 13是Enter的别名
                    console.log(event.target.value);
                }
            },
        })
    </script>
</body>

</html>